home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / prg_basi / ddfedit.zip / DDFBTR.BAS < prev    next >
BASIC Source File  |  1996-02-05  |  32KB  |  1,131 lines

  1. Option Explicit
  2.  
  3. Global Curr_File_Changed As Integer ' Global flag used when changing fields
  4. Global NewDictPath As String ' global.. for use when loading dicts. from another directory
  5.  
  6.  
  7. ' note, as vb does not accept "$" in a declaration
  8. ' I have changed all "$" into "D"
  9.  
  10. ' ********************************************************************************
  11. ' This is the structure of the FILE.DDF RecLen 97 bytes
  12. '
  13. ' keys are as follows :
  14. ' Key  0  Part  0   Unique    XfDid     Position  1   len  2     Ascending (int)
  15. ' Key  1  Part  0   Non-Uniq  XfDName   Position  3   len 20     Ascending (string)
  16. Type XDFile_def
  17.   XFDid As Integer                          ' File ID Starting from 1 (Unique)
  18.   XFDName As String * 20                    ' FileName
  19.   XFDLocation As String * 64                ' File Location i.e. Full Path
  20.   XFDFlags As String * 1 ' (1 byte int)     ' Bit 4=1 for Dict Files, 0 For User
  21.   XFDReserved As String * 10                ' Reserved
  22. End Type
  23.  
  24.  
  25. Type XDFileKey0_def
  26.   XFDid As Integer                          ' File ID Starting from 1 (Unique)
  27. End Type
  28.  
  29. ' ********************************************************************************
  30. ' This is the structure of the FILED.DDF RecLen 32 bytes
  31. '
  32. ' keys are as follows :
  33. ' Key  0  Part  0   Unique    XeDid     Position  1   len  2     Ascending (int)
  34. ' Key  1  Part  0   Non-Uniq  XeDFile   Position  3   len  2     Ascending (int)
  35. ' Key  2  Part  0   Non-Uniq  XeDName   Position  5   len  20    Ascending (string)
  36. ' Key  3  Part  0   Unique    XeDFile   Position  3   len  2     Ascending (int) - CONT
  37. ' Key  3  Part  1   Unique    XeDName   Position  5   len  20    Ascending (string)
  38.  
  39.  
  40. Type XDFieldKey1_def
  41.   XeDFile As Integer
  42. End Type
  43.  
  44.  
  45. Type XDField_def
  46.   XeDid As Integer                          ' Field ID Starting from 1 (Unique)
  47.   XeDFile As Integer                        ' File ID (XfDid in  FILE.DDF Above)
  48.   XeDName As String * 20                    ' Field Name (May have duplicates)
  49.   XeDDataType As String * 1 ' (1 byte int)  ' Field Type (0-13) See Below
  50.   XeDOffset As Integer                      ' Field Offset starting from 0
  51.   XeDSize As Integer                        ' Field Size
  52.   XedDec As String * 1 ' (1 byte int)       ' Decimal places (for Decimal Types)
  53.   XeDFlags As Integer                       ' Reserved
  54. End Type
  55.  
  56.  
  57. ' ********************************************************************************
  58. ' This is the structure of the INDEX.DDF RecLen 10 bytes
  59. '
  60. ' keys are as follows :
  61. ' Key  0  Part  0   Non_uniq  XiDFile    Position  1   len  2     Ascending (int)
  62. ' Key  1  Part  0   Non-Uniq  XiDField   Position  3   len  2     Ascending (int)
  63.  
  64. Type XDIndexKey0_def
  65.   XiDFile As Integer
  66. End Type
  67.  
  68.  
  69. Type XDIndex_def
  70.   XiDFile As Integer                        ' File ID (XfDid in  FILE.DDF Above)
  71.   XidField As Integer                       ' Filed ID (XeDid in FILED.DFF above)
  72.   XidNumber As Integer                      ' Key Number (0-->)
  73.   XiDPart As Integer                        ' Key Part (Segment of above, from 0-->)
  74.   XiDFlags As Integer                       ' Flags of Key
  75. End Type
  76.  
  77. ' XiDFlags can be :
  78. '   K_DUP = 1
  79. '   K_MOD = 2
  80. '   K_BIN = 4
  81. '   K_NUL = 8
  82. '   K_SEG = 16
  83. '   K_SEQ = 32
  84. '   K_DEC = 64
  85. '   K_SUP = 128
  86. '   K_EXT = 256
  87. '   K_MAN = 512
  88.  
  89. Type TempField_Def
  90.    FieldID As Integer
  91.    Position As Integer
  92.    Length As Integer
  93.    Type As Integer
  94. End Type
  95.  
  96. Function AddRecordToFieldDDF (PosBlk As PosBlkDef, XeDFile As Integer, XeDName As String, XeDDataType As Integer, XeDOffset As Integer, XeDSize As Integer, XedDec As Integer, XeDFlags As Integer) As Integer
  97.   
  98.   Dim Keybuf As KeyBufDef
  99.   Dim KeyBufLen As Integer
  100.   Dim XDField As XDField_def
  101.   Dim BufLen As Integer
  102.   Dim stat As Integer
  103.   Dim NextID As Integer
  104.  
  105.   KeyBufLen = Len(Keybuf)
  106.   BufLen = Len(XDField)
  107.   
  108.   
  109.   stat = btrcall(B_GETHI, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  110.   If stat <> 0 Then
  111.     If stat = 9 Then
  112.       NextID = 1
  113.     Else
  114.       MsgBox "Btrieve Error Inserting Record in FILE file " & Chr(10) & stat & " " & BtErr(stat)
  115.       AddRecordToFieldDDF = False
  116.       stat = btrcall(B_CLOSE, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  117.       Exit Function
  118.     End If
  119.   Else
  120.     NextID = XDField.XeDid + 1
  121.   End If
  122.   status "ADDING TO FIELD.DDF WITH ID " & NextID
  123.   
  124.   
  125.   XDField.XeDid = NextID
  126.   XDField.XeDFile = XeDFile
  127.   XDField.XeDName = XeDName
  128.   XDField.XeDDataType = Chr(XeDDataType)
  129.   XDField.XeDOffset = XeDOffset
  130.   XDField.XeDSize = XeDSize
  131.   XDField.XedDec = Chr(XedDec)
  132.   XDField.XeDFlags = XeDFlags
  133.   
  134.   KeyBufLen = Len(Keybuf)
  135.   BufLen = Len(XDField)
  136.   
  137.   stat = btrcall(B_INSERT, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  138.   If stat <> 0 Then
  139.     MsgBox "Btrieve Error Inserting Record in FIELD file " & Chr(10) & stat & " " & BtErr(stat)
  140.     AddRecordToFieldDDF = False
  141.     stat = btrcall(B_CLOSE, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  142.     Exit Function
  143.   End If
  144.   
  145.   AddRecordToFieldDDF = True
  146.  
  147.  
  148.   
  149.  
  150. End Function
  151.  
  152. Function AddRecordToFileDDF (XFDid As Integer, PosBlk As PosBlkDef, XFDName As String, XFDLocation As String, XFDFlags As Integer, XFDReserved As String) As Integer
  153.   Dim Keybuf As KeyBufDef
  154.   Dim KeyBufLen As Integer
  155.   Dim XDfile As XDFile_def
  156.   Dim BufLen As Integer
  157.   Dim stat As Integer
  158.   Dim NextID As Integer
  159.   Dim XDFileKey0 As XDFileKey0_def
  160.  
  161.   KeyBufLen = Len(Keybuf)
  162.   BufLen = Len(XDfile)
  163.   
  164.   
  165.   ' First Find the last record used on key=0, XF$ID
  166.   If XFDid = -1 Then
  167.     BufLen = Len(XDfile): KeyBufLen = Len(Keybuf)
  168.     stat = btrcall(B_GETHI, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  169.     If stat <> 0 Then
  170.       If stat = 9 Then
  171.         NextID = 1
  172.       Else
  173.         MsgBox "Btrieve Error Inserting Record in FILE file " & Chr(10) & stat & " " & BtErr(stat)
  174.         AddRecordToFileDDF = False
  175.         stat = btrcall(B_CLOSE, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  176.         Exit Function
  177.       End If
  178.     Else
  179.       NextID = XDfile.XFDid + 1
  180.     End If
  181.     status "ADDING TO FILE.DDF WITH ID " & NextID
  182.   Else
  183.     XDFileKey0.XFDid = XFDid
  184.     BufLen = Len(XDfile): KeyBufLen = Len(XDFileKey0)
  185.     stat = btrcall(B_GETEQ, PosBlk, XDfile, BufLen, XDFileKey0, KeyBufLen, 0)
  186.     If stat <> 0 Then
  187.       MsgBox "Btrieve Error Inserting Record in FILE file " & Chr(10) & stat & " " & BtErr(stat)
  188.       AddRecordToFileDDF = False
  189.       stat = btrcall(B_CLOSE, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  190.       Exit Function
  191.     Else
  192.       NextID = XFDid
  193.       status "UPDATING TO FILE.DDF WITH ID " & NextID
  194.     End If
  195.   
  196.   End If
  197.   
  198.   XDfile.XFDid = NextID
  199.   XDfile.XFDName = XFDName
  200.   XDfile.XFDLocation = XFDLocation
  201.   XDfile.XFDFlags = Chr(XFDFlags)
  202.   XDfile.XFDReserved = XFDReserved
  203.   KeyBufLen = Len(Keybuf)
  204.   BufLen = Len(XDfile)
  205.   
  206.   If XFDid = -1 Then
  207.     stat = btrcall(B_INSERT, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  208.   Else
  209.     stat = btrcall(B_UPDATE, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  210.   End If
  211.   
  212.   If stat <> 0 Then
  213.     MsgBox "Btrieve Error Inserting/Updating Record in FILE file " & Chr(10) & stat & " " & BtErr(stat)
  214.     AddRecordToFileDDF = False
  215.     stat = btrcall(B_CLOSE, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  216.     Exit Function
  217.   End If
  218.   
  219.   AddRecordToFileDDF = True
  220.  
  221. End Function
  222.  
  223. Function AddRecordToIndexDDF (PosBlk As PosBlkDef, XiDFile As Integer, XidField As Integer, XidNumber As Integer, XiDPart As Integer, XiDFlags As Integer) As Integer
  224.   Dim Keybuf As KeyBufDef
  225.   Dim KeyBufLen As Integer
  226.   Dim XDindex As XDIndex_def
  227.   Dim BufLen As Integer
  228.   Dim stat As Integer
  229.  
  230.  
  231.  
  232. ' XiDFile As Integer,
  233. ' XiDField As Ingeger,
  234. ' XiDNumber As Integer,
  235. ' XiDPart As Integer,
  236. ' XiDFlags As Integer
  237.   
  238.   KeyBufLen = Len(Keybuf)
  239.   BufLen = Len(XDindex)
  240.   XDindex.XiDFile = XiDFile
  241.   XDindex.XidField = XidField
  242.   XDindex.XidNumber = XidNumber
  243.   XDindex.XiDPart = XiDPart
  244.   XDindex.XiDFlags = XiDFlags
  245.   
  246.   stat = btrcall(B_INSERT, PosBlk, XDindex, BufLen, Keybuf, KeyBufLen, 0)
  247.   If stat <> 0 Then
  248.     MsgBox "Btrieve Error Inserting Record in Index file" & Chr(10) & stat & " " & BtErr(stat)
  249.     AddRecordToIndexDDF = False
  250.     stat = btrcall(B_CLOSE, PosBlk, XDindex, BufLen, Keybuf, KeyBufLen, 0)
  251.     Exit Function
  252.   End If
  253.   
  254.   AddRecordToIndexDDF = True
  255.  
  256.  
  257.  
  258. End Function
  259.  
  260. Function BtrDate (YY As Long, MM As Long, DD As Long) As Long
  261.   ' converts YYMMDD into Btrieve Date type
  262.  
  263.   BtrDate = YY * 65536 + MM * 256 + DD
  264.  
  265. End Function
  266.  
  267. Function BtrTime (hh As Long, MM As Long, SS As Long) As Long
  268.   BtrTime = hh * 16777216 + MM * 65536 + SS * 256
  269. End Function
  270.  
  271. Sub Create_btrfile (XPath As String, Location As String, FileID As Integer)
  272.   
  273.   Dim stat As Integer
  274.   
  275.   Dim Keybuf As KeyBufDef
  276.   Dim KeyBufLen As Integer
  277.   Dim BufLen As Integer
  278.   Dim FileBuf As FileBufDef
  279.   Dim KeyNum As Integer
  280.   Dim PosBlk As PosBlkDef
  281.   Dim FileFullPath As String
  282.   Dim i As Integer
  283.  
  284.   Dim XDField As XDField_def
  285.   Dim XDFieldKey1 As XDFieldKey1_def
  286.   Dim FileSize As Integer
  287.  
  288.   Dim XDindex As XDIndex_def
  289.   Dim XDIndexKey0 As XDIndexKey0_def
  290.   Dim IndexLast As Integer
  291.  
  292.   Dim TempField() As TempField_Def
  293.   Dim FieldLast As Integer
  294.  
  295. ' I need an array to store the Field information as follows :
  296. '    FieldID .. so we can look it up with the key
  297. '    Position = ' (Start From 1 and then add length of previous field !
  298. '    Length = '
  299.  
  300.  
  301. ' **************************************************************************************************
  302. ' first I have to work out the total length of the file by looking up its fields in FIELD.DDF
  303. ' **************************************************************************************************
  304.  
  305.   KeyBufLen = Len(Keybuf)
  306.   BufLen = Len(XDField)
  307.  
  308.   ' first open the file
  309.   FileFullPath = XPath & "Field.DDF"
  310.   Keybuf.kb = FileFullPath
  311.   KeyBufLen = Len(Keybuf)
  312.   BufLen = 0
  313.   
  314.   stat = btrcall(B_OPEN, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  315.   If stat <> 0 Then
  316.     MsgBox "Btrieve Error Opening file " & FileFullPath & Chr(10) & stat & " " & BtErr(stat)
  317.     Exit Sub
  318.   End If
  319.  
  320.  
  321.   KeyBufLen = Len(XDFieldKey1): BufLen = Len(XDField)
  322.   XDFieldKey1.XeDFile = FileID
  323.   
  324.   stat = btrcall(B_GETGE, PosBlk, XDField, BufLen, XDFieldKey1, KeyBufLen, 1)
  325.   FieldLast = 0
  326.   FileSize = 0
  327.   Do
  328.     If stat <> 0 Then Exit Do
  329.     If XDField.XeDFile <> FileID Then Exit Do
  330.     ReDim Preserve TempField(FieldLast)
  331.     TempField(FieldLast).FieldID = XDField.XeDid
  332.     TempField(FieldLast).Position = FileSize + 1
  333.     TempField(FieldLast).Length = XDField.XeDSize
  334.     TempField(FieldLast).Type = Asc(XDField.XeDDataType)
  335.     
  336.     FileSize = FileSize + XDField.XeDOffset
  337.     FieldLast = FieldLast + 1
  338.  
  339.     KeyBufLen = Len(XDFieldKey1): BufLen = Len(XDField)
  340.     stat = btrcall(B_GETNX, PosBlk, XDField, BufLen, XDFieldKey1, KeyBufLen, 1)
  341.   
  342.   Loop
  343.  
  344.   If (stat <> 9 And stat <> 0) Then MsgBox "Btrieve Error Retrieving Record in FILE file " & Chr(10) & stat & " " & BtErr(stat)
  345.   stat = btrcall(B_CLOSE, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  346.  
  347.   If FieldLast = 0 Then
  348.     MsgBox "File has NO fields.. It CANNOT be Created !", , "Create File"
  349.     Exit Sub
  350.   End If
  351.  
  352. ' **************************************************************************************************
  353. ' now I have to work my way through INDEX.DDF to set up the indexes
  354. ' **************************************************************************************************
  355.   
  356.  
  357.   
  358. 'Type XDIndexKey0_def
  359. '  XiDFile As Integer
  360. 'End Type
  361.   
  362.  
  363.   KeyBufLen = Len(Keybuf)
  364.   BufLen = Len(XDindex)
  365.  
  366.   ' first open the file
  367.   FileFullPath = XPath & "Index.DDF"
  368.   Keybuf.kb = FileFullPath
  369.   KeyBufLen = Len(Keybuf)
  370.   BufLen = 0
  371.   
  372.   stat = btrcall(B_OPEN, PosBlk, XDindex, BufLen, Keybuf, KeyBufLen, 0)
  373.   If stat <> 0 Then
  374.     MsgBox "Btrieve Error Opening file " & FileFullPath & Chr(10) & stat & " " & BtErr(stat)
  375.     Exit Sub
  376.   End If
  377.  
  378.  
  379.   KeyBufLen = Len(XDIndexKey0): BufLen = Len(XDindex)
  380.   XDIndexKey0.XiDFile = FileID
  381.   IndexLast = 0
  382.   stat = btrcall(B_GETGE, PosBlk, XDindex, BufLen, XDIndexKey0, KeyBufLen, 0)
  383.   Do
  384.     If stat <> 0 Then Exit Do
  385.     If XDindex.XiDFile <> FileID Then Exit Do
  386.   
  387.     For i = 0 To FieldLast - 1
  388.       If TempField(i).FieldID = XDindex.XidField Then
  389.         FileBuf.KeySpec(IndexLast).Position = TempField(i).Position
  390.         FileBuf.KeySpec(IndexLast).Length = TempField(i).Length
  391.         FileBuf.KeySpec(IndexLast).Flags = XDindex.XiDFlags
  392.         FileBuf.KeySpec(IndexLast).Type = TempField(i).Type
  393.         Exit For
  394.       End If
  395.     Next i
  396.     IndexLast = IndexLast + 1
  397.    
  398.     KeyBufLen = Len(XDIndexKey0): BufLen = Len(XDindex)
  399.     stat = btrcall(B_GETNX, PosBlk, XDindex, BufLen, XDIndexKey0, KeyBufLen, 0)
  400.   
  401.   Loop
  402.  
  403.   If (stat <> 9 And stat <> 0) Then MsgBox "Btrieve Error Retrieving Record in FILE file " & Chr(10) & stat & " " & BtErr(stat)
  404.   stat = btrcall(B_CLOSE, PosBlk, XDindex, BufLen, Keybuf, KeyBufLen, 0)
  405.   
  406.  
  407. ' **************************************************************************************************
  408. ' Now I can Finally Create the file !
  409. ' **************************************************************************************************
  410.   
  411.   FileBuf.RecLen = FileSize
  412.   FileBuf.PageSize = 1024
  413.   FileBuf.IndxCnt = IndexLast
  414.   FileBuf.FileFlags = 0
  415.  
  416.   Keybuf.kb = Location
  417.   
  418.   status "Creating  file " & Location
  419.  
  420.  
  421.   KeyBufLen = Len(Keybuf)
  422.   KeyNum = 0
  423.   
  424.  
  425.   stat = btrcall(B_CREATE, PosBlk, FileBuf, Len(FileBuf), Keybuf, Len(Keybuf), KeyNum)
  426.  
  427.   If stat <> 0 Then
  428.     MsgBox "Btrieve Error Creating file " & Keybuf.kb & Chr(10) & stat & " " & BtErr(stat)
  429.     Exit Sub
  430.   End If
  431.   
  432.   MsgBox "File Creation OK !", , "Create File"
  433.   status ""
  434. End Sub
  435.  
  436. Sub CreateDummyFile ()
  437.   ' This Function SHOULD create new Dictionary Files FILE.DDF and FIELD.DDF
  438.   ' and add the first records to them
  439.  
  440.   ' *** TO DO
  441.   ' Check if File Exists
  442.   ' Initialize btrieve
  443.  
  444.   Dim i As Integer
  445.   Dim XPath As String
  446.   XPath = "C:\VB\"
  447.  
  448.   Dim stat As Integer
  449.   
  450.   Dim Keybuf As KeyBufDef
  451.   Dim KeyBufLen As Integer
  452.   
  453.   Dim FileBuf As FileBufDef
  454.   
  455.   Dim KeyNum As Integer
  456.   Dim PosBlk As PosBlkDef
  457.   
  458.   Dim XDfile As XDFile_def
  459.   Dim XDField As XDField_def
  460.   Dim XDindex As XDIndex_def
  461.  
  462.   
  463. ' This is a dummy, just to create a file with all possible data type indexes
  464.  
  465.   
  466.   FileBuf.RecLen = 40
  467.   FileBuf.PageSize = 1024
  468.   FileBuf.IndxCnt = 16
  469.   FileBuf.FileFlags = 0
  470.  
  471.  
  472.   FileBuf.KeySpec(0).Position = 1
  473.   FileBuf.KeySpec(1).Position = 3
  474.   FileBuf.KeySpec(2).Position = 5
  475.   FileBuf.KeySpec(3).Position = 7
  476.   FileBuf.KeySpec(4).Position = 9
  477.   FileBuf.KeySpec(5).Position = 11
  478.   FileBuf.KeySpec(6).Position = 13
  479.   FileBuf.KeySpec(7).Position = 15
  480.   FileBuf.KeySpec(8).Position = 17
  481.   FileBuf.KeySpec(9).Position = 19
  482.   FileBuf.KeySpec(10).Position = 21
  483.   FileBuf.KeySpec(11).Position = 23
  484.   FileBuf.KeySpec(12).Position = 25
  485.   FileBuf.KeySpec(13).Position = 27
  486.   FileBuf.KeySpec(14).Position = 29
  487.   FileBuf.KeySpec(15).Position = 31
  488.   
  489.   FileBuf.KeySpec(0).Length = 2
  490.   FileBuf.KeySpec(1).Length = 2
  491.   FileBuf.KeySpec(2).Length = 2
  492.   FileBuf.KeySpec(3).Length = 2
  493.   FileBuf.KeySpec(4).Length = 2
  494.   FileBuf.KeySpec(5).Length = 2
  495.   FileBuf.KeySpec(6).Length = 2
  496.   FileBuf.KeySpec(7).Length = 2
  497.   FileBuf.KeySpec(8).Length = 2
  498.   FileBuf.KeySpec(9).Length = 2
  499.   FileBuf.KeySpec(10).Length = 2
  500.   FileBuf.KeySpec(11).Length = 2
  501.   FileBuf.KeySpec(12).Length = 2
  502.   FileBuf.KeySpec(13).Length = 2
  503.   FileBuf.KeySpec(14).Length = 2
  504.   FileBuf.KeySpec(15).Length = 2
  505.  
  506.  
  507.   FileBuf.KeySpec(0).Flags = K_EXT
  508.   FileBuf.KeySpec(1).Flags = K_EXT
  509.   FileBuf.KeySpec(2).Flags = K_EXT
  510.   FileBuf.KeySpec(3).Flags = K_EXT
  511.   FileBuf.KeySpec(4).Flags = K_EXT
  512.   FileBuf.KeySpec(5).Flags = K_EXT
  513.   FileBuf.KeySpec(6).Flags = K_EXT
  514.   FileBuf.KeySpec(7).Flags = K_EXT
  515.   FileBuf.KeySpec(8).Flags = K_EXT
  516.   FileBuf.KeySpec(9).Flags = K_EXT
  517.   FileBuf.KeySpec(10).Flags = K_EXT
  518.   FileBuf.KeySpec(11).Flags = K_EXT
  519.   FileBuf.KeySpec(12).Flags = K_EXT
  520.   FileBuf.KeySpec(13).Flags = K_EXT
  521.   FileBuf.KeySpec(14).Flags = K_EXT
  522.   FileBuf.KeySpec(15).Flags = K_EXT
  523.  
  524.  
  525.   For i = 0 To 15
  526.     FileBuf.KeySpec(i).Type = 0
  527.   Next i
  528.  
  529.  
  530.   FileBuf.KeySpec(0).Type = 0
  531.   FileBuf.KeySpec(1).Type = 1
  532.   FileBuf.KeySpec(2).Type = 2
  533.   FileBuf.KeySpec(3).Type = 3
  534.   FileBuf.KeySpec(4).Type = 4
  535.   FileBuf.KeySpec(5).Type = 5
  536.   FileBuf.KeySpec(6).Type = 6
  537.   FileBuf.KeySpec(7).Type = 7
  538.   FileBuf.KeySpec(8).Type = 8
  539.   FileBuf.KeySpec(9).Type = 9
  540.   FileBuf.KeySpec(10).Type = 10
  541.   FileBuf.KeySpec(11).Type = 11
  542.  ' FileBuf.KeySpec(12).Type = 12
  543.  ' FileBuf.KeySpec(13).Type = 13
  544.   FileBuf.KeySpec(14).Type = 14
  545.   FileBuf.KeySpec(15).Type = 15
  546.  
  547.  
  548.   
  549.  
  550.  
  551.  
  552.  
  553.  
  554.   Keybuf.kb = XPath & "TEST.DDF"
  555.   KeyBufLen = Len(Keybuf)
  556.   KeyNum = 0
  557.   
  558.   
  559.   status "Creating  file " & Keybuf.kb
  560.  
  561.   stat = btrcall(B_CREATE, PosBlk, FileBuf, Len(FileBuf), Keybuf, Len(Keybuf), KeyNum)
  562.  
  563.   If stat <> 0 Then
  564.     MsgBox "Btrieve Error Creating file " & Keybuf.kb & Chr(10) & stat & " " & BtErr(stat)
  565.     
  566.     Exit Sub
  567.   End If
  568.  
  569.   Debug.Print "DUMMY FILE CREATED !"
  570.   
  571.  
  572. End Sub
  573.  
  574. Sub DictionaryCreate (XPath As String)
  575.   Dim X As Integer
  576.  
  577.   X = NewDictCreateFiles(XPath)
  578.   If X <> True Then
  579.     Exit Sub
  580.   End If
  581.  
  582.   X = NewDictInitFiles(XPath)
  583.   If X <> True Then
  584.     Exit Sub
  585.   End If
  586.  
  587.   status ""
  588.  
  589. End Sub
  590.  
  591. Sub Fields_Remove (XPath As String, XFDid As Integer)
  592.   ' Remove all Field references for the current file XfDid
  593.   ' XPath & Field.ddf
  594.  
  595.   Dim stat As Integer
  596.   Dim KeyNum As Integer
  597.   Dim PosBlk As PosBlkDef
  598.   Dim Keybuf As KeyBufDef
  599.   Dim KeyBufLen As Integer
  600.   Dim BufLen As Integer
  601.   Dim FileFullPath As String
  602.   Dim XDField As XDField_def
  603.   Dim XDFieldKey1 As XDFieldKey1_def
  604.   
  605. ' Curr_XFDid
  606. ' ************************************************************************************
  607. ' Now we remove records to the FIELD.DDF file
  608. ' ************************************************************************************
  609.  
  610.   FileFullPath = XPath & "FIELD.DDF"
  611.   Keybuf.kb = FileFullPath
  612.   KeyBufLen = Len(Keybuf)
  613.   BufLen = 0
  614.  
  615.   
  616.   status "Removing Fields from file " & FileFullPath
  617.   
  618.   stat = btrcall(B_OPEN, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  619.   If stat <> 0 Then
  620.     MsgBox "Btrieve Error Opening file " & FileFullPath & Chr(10) & stat & " " & BtErr(stat)
  621.     Exit Sub
  622.   End If
  623.  
  624.   
  625.   Do
  626.     XDFieldKey1.XeDFile = XFDid
  627.     BufLen = Len(XDField): KeyBufLen = Len(XDFieldKey1)
  628.     stat = btrcall(B_GETEQ, PosBlk, XDField, BufLen, XDFieldKey1, KeyBufLen, 1)
  629.     If stat > 0 Then Exit Do
  630.     stat = btrcall(B_DEL, PosBlk, XDField, BufLen, XDFieldKey1, KeyBufLen, 1)
  631.     Debug.Print "Status "; stat
  632.   Loop
  633.   
  634.   stat = btrcall(B_CLOSE, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  635.   
  636.   status ""
  637. End Sub
  638.  
  639. Sub File_Remove (XPath As String, XFDid As Integer)
  640.     
  641.  
  642.   Dim Keybuf As KeyBufDef
  643.   Dim KeyBufLen As Integer
  644.   Dim XDfile As XDFile_def
  645.   Dim XDFileKey0  As XDFileKey0_def
  646.   Dim BufLen As Integer
  647.   Dim stat As Integer
  648.   Dim PosBlk As PosBlkDef
  649.   Dim FileFullPath As String
  650.   Dim X As Integer
  651.   Dim WhosFile As String
  652.  
  653.   
  654.  
  655.   KeyBufLen = Len(Keybuf)
  656.   BufLen = Len(XDfile)
  657.  
  658.   ' first open the file
  659.   FileFullPath = XPath & "FILE.DDF"
  660.   Keybuf.kb = FileFullPath
  661.   KeyBufLen = Len(Keybuf)
  662.   BufLen = 0
  663.   
  664.   stat = btrcall(B_OPEN, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  665.   If stat <> 0 Then
  666.     MsgBox "Btrieve Error Opening file " & FileFullPath & Chr(10) & stat & " " & BtErr(stat)
  667.     Exit Sub
  668.   End If
  669.  
  670.  
  671.   XDFileKey0.XFDid = XFDid
  672.   KeyBufLen = Len(XDFileKey0): BufLen = Len(XDfile)
  673.   stat = btrcall(B_GETEQ, PosBlk, XDfile, BufLen, XDFileKey0, KeyBufLen, 0)
  674.   If stat Then
  675.     MsgBox "Error Finding Record " & BtErr(stat)
  676.     Exit Sub
  677.   End If
  678.   stat = btrcall(B_DEL, PosBlk, XDfile, BufLen, XDFileKey0, KeyBufLen, 0)
  679.   If stat Then
  680.     MsgBox "Error Deleting Record " & BtErr(stat)
  681.     Exit Sub
  682.   End If
  683.   
  684.   stat = btrcall(B_CLOSE, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  685.   
  686.   Fields_Remove XPath, XFDid
  687.  
  688. End Sub
  689.  
  690. Function FileExist (Fullpath As String) As Integer
  691.   On Error GoTo NotExist
  692.  
  693.   Open Fullpath For Input As #1
  694.   Close #1
  695.   FileExist = True
  696.   Exit Function
  697.  
  698. NotExist:
  699.   FileExist = False
  700.   Exit Function
  701.  
  702.  
  703. End Function
  704.  
  705. Sub Indexes_Remove (XPath As String, XFDid As Integer)
  706.   ' Remove all Index references for the current file XfDid
  707.   ' XPath & Index.ddf
  708.  
  709.   Dim stat As Integer
  710.   Dim KeyNum As Integer
  711.   Dim PosBlk As PosBlkDef
  712.   Dim Keybuf As KeyBufDef
  713.   Dim KeyBufLen As Integer
  714.   Dim BufLen As Integer
  715.   Dim FileFullPath As String
  716.   Dim XDindex As XDIndex_def
  717.   Dim XDIndexKey0 As XDIndexKey0_def
  718.   
  719. ' Curr_XFDid
  720. ' ************************************************************************************
  721. ' Now we remove records to the Index.DDF file
  722. ' ************************************************************************************
  723.  
  724.   FileFullPath = XPath & "Index.DDF"
  725.   Keybuf.kb = FileFullPath
  726.   KeyBufLen = Len(Keybuf)
  727.   BufLen = 0
  728.  
  729.   
  730.   status "Removing Indexes from file " & FileFullPath
  731.   
  732.   stat = btrcall(B_OPEN, PosBlk, XDindex, BufLen, Keybuf, KeyBufLen, 0)
  733.   If stat <> 0 Then
  734.     MsgBox "Btrieve Error Opening file " & FileFullPath & Chr(10) & stat & " " & BtErr(stat)
  735.     Exit Sub
  736.   End If
  737.  
  738.   
  739.   Do
  740.     XDIndexKey0.XiDFile = XFDid
  741.     BufLen = Len(XDindex): KeyBufLen = Len(XDIndexKey0)
  742.     stat = btrcall(B_GETEQ, PosBlk, XDindex, BufLen, XDIndexKey0, KeyBufLen, 0)
  743.     If stat > 0 Then Exit Do
  744.     stat = btrcall(B_DEL, PosBlk, XDindex, BufLen, XDIndexKey0, KeyBufLen, 0)
  745.     Debug.Print "Status "; stat
  746.   Loop
  747.   
  748.   stat = btrcall(B_CLOSE, PosBlk, XDindex, BufLen, Keybuf, KeyBufLen, 0)
  749.   
  750.   status ""
  751.  
  752. End Sub
  753.  
  754. Sub Main ()
  755.   
  756.  
  757.   Load MainForm
  758.   MainForm.Caption = "DDF Creator"
  759.   MainForm.Show
  760.  
  761.  
  762.  
  763.  
  764. '  DictionaryCreate "C:\VB\"
  765. '  FileDDFEdit "C:\VB\"
  766. '  FieldDDFEdit "C:\VB\"
  767.   
  768.   
  769. End Sub
  770.  
  771. Function NewDictCreateFiles (XPath As String) As Integer
  772.   ' This Function SHOULD create new Dictionary Files FILE.DDF and FIELD.DDF
  773.   ' and add the first records to them
  774.  
  775.   ' *** TO DO
  776.   ' Check if File Exists
  777.   ' Initialize btrieve
  778.  
  779.   
  780.   Dim stat As Integer
  781.   
  782.   Dim Keybuf As KeyBufDef
  783.   Dim KeyBufLen As Integer
  784.   
  785.   Dim FileBuf As FileBufDef
  786.   
  787.   Dim KeyNum As Integer
  788.   Dim PosBlk As PosBlkDef
  789.   
  790.   Dim XDfile As XDFile_def
  791.   Dim XDField As XDField_def
  792.   Dim XDindex As XDIndex_def
  793.  
  794.   
  795.   status "Creating new dictionary files in " & XPath
  796.  
  797. ' ************************************************************************************
  798. ' First Create the FILE.DDF RecLen 97 bytes
  799. ' ************************************************************************************
  800.   
  801.  
  802.   FileBuf.RecLen = Len(XDfile)
  803.   FileBuf.PageSize = 1024
  804.   FileBuf.IndxCnt = 2
  805.   FileBuf.FileFlags = 0
  806.  
  807. ' Key  0  Part  0   Unique    XfDid     Position  1   len  2     Ascending
  808.   FileBuf.KeySpec(0).Position = 1
  809.   FileBuf.KeySpec(0).Length = 2
  810.   FileBuf.KeySpec(0).Flags = K_MOD + K_EXT
  811.   FileBuf.KeySpec(0).Type = K_T_NUM
  812.  
  813. ' Key  1  Part  0   Non-Uniq  XfDName   Position  3   len 20     Ascending
  814.   FileBuf.KeySpec(1).Position = 3
  815.   FileBuf.KeySpec(1).Length = 20
  816.   FileBuf.KeySpec(1).Flags = K_MOD + K_EXT
  817.   FileBuf.KeySpec(1).Type = K_T_STR
  818.  
  819.  
  820.   Keybuf.kb = XPath & "FILE.DDF"
  821.   
  822.   status "Creating  file " & Keybuf.kb
  823.  
  824.  
  825.   KeyBufLen = Len(Keybuf)
  826.   KeyNum = 0
  827.   
  828.  
  829.   stat = btrcall(B_CREATE, PosBlk, FileBuf, Len(FileBuf), Keybuf, Len(Keybuf), KeyNum)
  830.  
  831.   If stat <> 0 Then
  832.     MsgBox "Btrieve Error Creating file " & Keybuf.kb & Chr(10) & stat & " " & BtErr(stat)
  833.     NewDictCreateFiles = False
  834.     Exit Function
  835.   End If
  836.   
  837.  
  838. ' ************************************************************************************
  839. ' Now Create the  FIELD.DDF RecLen 32 bytes
  840. ' ************************************************************************************
  841.   
  842.   FileBuf.RecLen = Len(XDField)
  843.   FileBuf.PageSize = 1024
  844.   FileBuf.IndxCnt = 4
  845.   FileBuf.FileFlags = 0
  846.  
  847.  
  848.  
  849. ' Key  0  Part  0   Unique    XeDid     Position  1   len  2     Ascending (int)
  850.   FileBuf.KeySpec(0).Position = 1
  851.   FileBuf.KeySpec(0).Length = 2
  852.   FileBuf.KeySpec(0).Flags = K_EXT
  853.   FileBuf.KeySpec(0).Type = K_T_BIN
  854.  
  855. ' Key  1  Part  0   Non-Uniq  XeDFile   Position  3   len  2     Ascending (int)
  856.   FileBuf.KeySpec(1).Position = 3
  857.   FileBuf.KeySpec(1).Length = 2
  858.   FileBuf.KeySpec(1).Flags = K_DUP + K_EXT
  859.   FileBuf.KeySpec(1).Type = K_T_BIN
  860.   
  861.   
  862. ' Key  2  Part  0   Non-Uniq  XeDName   Position  5   len  20    Ascending (string)
  863.   FileBuf.KeySpec(2).Position = 5
  864.   FileBuf.KeySpec(2).Length = 20
  865.   FileBuf.KeySpec(2).Flags = K_DUP + K_EXT
  866.   FileBuf.KeySpec(2).Type = K_T_STR
  867.  
  868.  
  869. ' Key  3  Part  0   Unique    XeDFile   Position  3   len  2     Ascending (int) - CONT
  870.   FileBuf.KeySpec(3).Position = 3
  871.   FileBuf.KeySpec(3).Length = 2
  872.   FileBuf.KeySpec(3).Flags = K_SEG + K_EXT
  873.   FileBuf.KeySpec(3).Type = K_T_BIN
  874.  
  875.  
  876. ' Key  3  Part  1   Unique    XeDName   Position  5   len  20    Ascending (string)
  877.   FileBuf.KeySpec(4).Position = 5
  878.   FileBuf.KeySpec(4).Length = 20
  879.   FileBuf.KeySpec(4).Flags = K_EXT
  880.   FileBuf.KeySpec(4).Type = K_T_STR
  881.   
  882.  
  883.  
  884.   
  885.   Keybuf.kb = XPath & "FIELD.DDF"
  886.   KeyBufLen = Len(Keybuf)
  887.   KeyNum = 0
  888.   
  889.   
  890.   status "Creating  file " & Keybuf.kb
  891.  
  892.   stat = btrcall(B_CREATE, PosBlk, FileBuf, Len(FileBuf), Keybuf, Len(Keybuf), KeyNum)
  893.                     
  894.   If stat <> 0 Then
  895.     MsgBox "Btrieve Error Creating file " & Keybuf.kb & Chr(10) & stat & " " & BtErr(stat)
  896.     NewDictCreateFiles = False
  897.     Exit Function
  898.   End If
  899.   
  900.   
  901.   
  902. ' ************************************************************************************
  903. ' Now Create the  INDEX.DDF RecLen 10 bytes
  904. ' ************************************************************************************
  905.   
  906.   FileBuf.RecLen = Len(XDindex)
  907.   FileBuf.PageSize = 1024
  908.   FileBuf.IndxCnt = 2
  909.   FileBuf.FileFlags = 0
  910.  
  911. ' Key  0  Part  0   Non_uniq  XiDFile    Position  1   len  2     Ascending (int)
  912.  
  913.  
  914.   FileBuf.KeySpec(0).Position = 1
  915.   FileBuf.KeySpec(0).Length = 2
  916.   FileBuf.KeySpec(0).Flags = K_DUP + K_EXT
  917.   FileBuf.KeySpec(0).Type = K_T_BIN
  918.  
  919. ' Key  1  Part  0   Non-Uniq  XiDField   Position  3   len  2     Ascending (int)
  920.   FileBuf.KeySpec(1).Position = 3
  921.   FileBuf.KeySpec(1).Length = 2
  922.   FileBuf.KeySpec(1).Flags = K_DUP + K_EXT
  923.   FileBuf.KeySpec(1).Type = K_T_BIN
  924.   
  925.   Keybuf.kb = XPath & "INDEX.DDF"
  926.   KeyBufLen = Len(Keybuf)
  927.   KeyNum = 0
  928.   
  929.   
  930.   status "Creating  file " & Keybuf.kb
  931.  
  932.   stat = btrcall(B_CREATE, PosBlk, FileBuf, Len(FileBuf), Keybuf, Len(Keybuf), KeyNum)
  933.  
  934.   If stat <> 0 Then
  935.     MsgBox "Btrieve Error Creating file " & Keybuf.kb & Chr(10) & stat & " " & BtErr(stat)
  936.     NewDictCreateFiles = False
  937.     Exit Function
  938.   End If
  939.   
  940.  
  941.  
  942.   NewDictCreateFiles = True
  943.  
  944. End Function
  945.  
  946. Function NewDictInitFiles (XPath As String) As Integer
  947.   Dim stat As Integer
  948.   
  949.   Dim KeyNum As Integer
  950.   Dim PosBlk As PosBlkDef
  951.   Dim Keybuf As KeyBufDef
  952.   Dim KeyBufLen As Integer
  953.   Dim BufLen As Integer
  954.   Dim FileFullPath As String
  955.  
  956.   Dim XDfile As XDFile_def
  957.   Dim XDField As XDField_def
  958.   
  959.  
  960. ' ************************************************************************************
  961. ' First Add Fields to the FILE.DDF file
  962. ' ************************************************************************************
  963.  
  964.   
  965.   FileFullPath = XPath & "FILE.DDF"
  966.   Keybuf.kb = FileFullPath
  967.   KeyBufLen = Len(Keybuf)
  968.   BufLen = 0
  969.  
  970.   
  971.   status "Adding Fields to file " & FileFullPath
  972.   
  973.   stat = btrcall(B_OPEN, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  974.   If stat <> 0 Then
  975.     MsgBox "Btrieve Error Opening file " & FileFullPath & Chr(10) & stat & " " & BtErr(stat)
  976.     NewDictInitFiles = False
  977.     Exit Function
  978.   End If
  979.  
  980.  
  981.   If AddRecordToFileDDF(-1, PosBlk, "X$File", XPath & "FILE.DDF", 16, "") = False Then
  982.     NewDictInitFiles = False
  983.     Exit Function
  984.   End If
  985.   
  986.   If AddRecordToFileDDF(-1, PosBlk, "X$Field", XPath & "FIELD.DDF", 16, "") = False Then
  987.     NewDictInitFiles = False
  988.     Exit Function
  989.   End If
  990.  
  991.   If AddRecordToFileDDF(-1, PosBlk, "X$Index", XPath & "INDEX.DDF", 16, "") = False Then
  992.     NewDictInitFiles = False
  993.     Exit Function
  994.   End If
  995.   
  996.   stat = btrcall(B_CLOSE, PosBlk, XDfile, BufLen, Keybuf, KeyBufLen, 0)
  997.  
  998.  
  999.  
  1000. ' ************************************************************************************
  1001. ' Now we add records to the FIELD.DDF file
  1002. ' ************************************************************************************
  1003.  
  1004.   FileFullPath = XPath & "FIELD.DDF"
  1005.   Keybuf.kb = FileFullPath
  1006.   KeyBufLen = Len(Keybuf)
  1007.   BufLen = 0
  1008.  
  1009.   
  1010.   status "Adding Fields to file " & FileFullPath
  1011.   
  1012.   
  1013.   
  1014.   stat = btrcall(B_OPEN, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  1015.   If stat <> 0 Then
  1016.     MsgBox "Btrieve Error Opening file " & FileFullPath & Chr(10) & stat & " " & BtErr(stat)
  1017.     NewDictInitFiles = False
  1018.     Exit Function
  1019.   End If
  1020.  
  1021.   ' Records for FILE.DDF
  1022.  
  1023.   If AddRecordToFieldDDF(PosBlk, 1, "Xf$id", 1, 0, 2, 0, 0) = False Then
  1024.     NewDictInitFiles = False
  1025.     Exit Function
  1026.   End If
  1027.   
  1028.  
  1029.   If AddRecordToFieldDDF(PosBlk, 1, "Xf$Name", 0, 2, 20, 0, 0) = False Then
  1030.     NewDictInitFiles = False
  1031.     Exit Function
  1032.   End If
  1033.  
  1034.   If AddRecordToFieldDDF(PosBlk, 1, "Xf$Loc", 0, 22, 64, 0, 0) = False Then
  1035.     NewDictInitFiles = False
  1036.     Exit Function
  1037.   End If
  1038.   
  1039.   If AddRecordToFieldDDF(PosBlk, 1, "Xf$Flags", 1, 86, 1, 0, 0) = False Then
  1040.     NewDictInitFiles = False
  1041.     Exit Function
  1042.   End If
  1043.   
  1044.  
  1045.   ' Records for FIELD.DDF
  1046.   
  1047.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$Id", 1, 0, 2, 0, 0) = False Then
  1048.     NewDictInitFiles = False
  1049.     Exit Function
  1050.   End If
  1051.  
  1052.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$File", 1, 2, 2, 0, 0) = False Then
  1053.     NewDictInitFiles = False
  1054.     Exit Function
  1055.   End If
  1056.  
  1057.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$Name", 0, 4, 20, 0, 0) = False Then
  1058.     NewDictInitFiles = False
  1059.     Exit Function
  1060.   End If
  1061.  
  1062.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$DataType", 1, 24, 1, 0, 0) = False Then
  1063.     NewDictInitFiles = False
  1064.     Exit Function
  1065.   End If
  1066.  
  1067.  
  1068.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$OffSet", 1, 25, 2, 0, 0) = False Then
  1069.     NewDictInitFiles = False
  1070.     Exit Function
  1071.   End If
  1072.  
  1073.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$Size", 1, 27, 2, 0, 0) = False Then
  1074.     NewDictInitFiles = False
  1075.     Exit Function
  1076.   End If
  1077.  
  1078.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$Dec", 1, 29, 1, 0, 0) = False Then
  1079.     NewDictInitFiles = False
  1080.     Exit Function
  1081.   End If
  1082.  
  1083.   If AddRecordToFieldDDF(PosBlk, 2, "Xe$Flags", 1, 30, 2, 0, 0) = False Then
  1084.     NewDictInitFiles = False
  1085.     Exit Function
  1086.   End If
  1087.  
  1088.   ' Records For INDEX.DDF
  1089.  
  1090.   If AddRecordToFieldDDF(PosBlk, 3, "Xi$File", 1, 0, 2, 0, 0) = False Then
  1091.     NewDictInitFiles = False
  1092.     Exit Function
  1093.   End If
  1094.   
  1095.   If AddRecordToFieldDDF(PosBlk, 3, "Xi$Field", 1, 2, 2, 0, 0) = False Then
  1096.     NewDictInitFiles = False
  1097.     Exit Function
  1098.   End If
  1099.   
  1100.   If AddRecordToFieldDDF(PosBlk, 3, "Xi$Number", 1, 4, 2, 0, 0) = False Then
  1101.     NewDictInitFiles = False
  1102.     Exit Function
  1103.   End If
  1104.   
  1105.   If AddRecordToFieldDDF(PosBlk, 3, "Xi$Part", 1, 6, 2, 0, 0) = False Then
  1106.     NewDictInitFiles = False
  1107.     Exit Function
  1108.   End If
  1109.   
  1110.   If AddRecordToFieldDDF(PosBlk, 3, "Xi$Flags", 1, 8, 2, 0, 0) = False Then
  1111.     NewDictInitFiles = False
  1112.     Exit Function
  1113.   End If
  1114.   
  1115.   
  1116.   stat = btrcall(B_CLOSE, PosBlk, XDField, BufLen, Keybuf, KeyBufLen, 0)
  1117.  
  1118.  
  1119.  
  1120.   NewDictInitFiles = True
  1121. End Function
  1122.  
  1123. Sub status (s As String)
  1124.   If s <> "" Then
  1125.     MainForm.PanMain.Caption = " STATUS : " & s
  1126.   Else
  1127.     MainForm.PanMain.Caption = ""
  1128.   End If
  1129. End Sub
  1130.  
  1131.